<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
</head>
<body>
	<div id="moduleHtml">
	 <div id="fileUploaderContainter">
      <input id="fileUploaderDom" name="file" type="file" />
      <div id="startUploaderButton">开始上传</div>
	  </div>
	</div>
</body>
  <script>
  //cofit_module_js
    Cofit.moduleSourceCode.file_uploader=function(dom){
      var module = {
        dom : $(dom) ,        
        inited : false , //是否已经初始化
        //显示
        show : function( directoryId ){//directoryId=要上传的路径id
		          var dom=$(module.dom);
		          var containter=dom.find("#fileUploaderContainter");
	        	  if(module.inited){
               containter.find("#startUploaderButton").click(function(){
                   containter.find("#fileUploaderDom").uploadify("settings","formData",{ directory_id : directoryId });
                   containter.find("#fileUploaderDom").uploadify("upload","*");
                 });
	        		  $(dom).dialog("open");
	        		  return ;
	        	  }
		          $("body").append(dom);
		          $(dom).dialog({    
		        	    title: "上传文件",    
		        	    width: 400,    
		        	    height: 200,    
		        	    closed: false,    
		        	    cache: false,    
		        	    modal: true   ,
		        	    onClose : function(){
		        	    	containter.find("#fileUploaderDom").uploadify("cancel","*");
		        	    } ,
		        	});
		          containter.find("#fileUploaderDom").uploadify({
		              height : 30,
		              swf : "static/js/uploadify/uploadify.swf" ,
		              uploader : "./file/upload_file" ,
		              width : 120 ,
		              fileObjName : "file" ,
		              auto : false ,
		              buttonText : "选择文件" ,
		          }); 
		          containter.find("#startUploaderButton").linkbutton({    
		        	    iconCls: 'icon-cd-upload'   
		          });  
             containter.find("#startUploaderButton").click(function(){
                 containter.find("#fileUploaderDom").uploadify("settings","formData",{ directory_id : directoryId });
                 containter.find("#fileUploaderDom").uploadify("upload","*");
               });
      	    	module.inited=true;
		          
	          
        },
      };
      return module;
    };
  //cofit_module_js
  </script>
</html>